package com.zh.common;

import lombok.Data;

@Data
public class Result {

    private Integer code;
    private String msg;
    private Object data;
    private Long total;

    public static Result fail(Object data) {
        Result result = new Result();
        result.setCode(400);
        result.setMsg("失败");
        result.setTotal(0L);
        result.setData(data);
        return result;
    }

    public static Result success(Object data,Long total) {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("成功");
        result.setData(data);
        result.setTotal(total);
        return result;
    }

    public static Result result(Integer code, String msg, Object data, Long total){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        result.setTotal(total);
        return result;
    }
}
